*** Data analysis - ITA ***

use "data_ITA"
*44 variables, 7454 observations

*** Data cleaning ***

**convert variables to numeric (from string) where possible
destring, replace

*identify the % of missing values
mdesc

**check unique identifier - OK
isid ResponseId
**check for duplicates - none
duplicates report

*Delete no consent/missing consent observations (95% remain)
tab consent, miss sort
keep if consent=="Accetto di partecipare"

*Delete wrong/missing answers newscomp1 (63% remain)
tab newscomp1, miss sort
keep if newscomp1=="â‚¬ 1.500"

*Delete wrong/missing answers newscomp2 (49% remain)
tab newscomp2, miss sort
keep if newscomp2=="PerchÃ© ha lasciato il suo documento"

drop consent newscomp1 newscomp2
*41 variables, 3633 observations

*** Analysis ***

**Gender
tab gender, m sort

**Age 
sum age, d

**Educational level
tab Q1439,m sort

**Employment status
tab Q1444, m sort

**Received first dose COVID-19 vaccine 
tab receivedvaccine, m sort
replace receivedvaccine="Si" if receivedvaccine=="Si, ho ricevuto la prima dose di AstraZeneca" | receivedvaccine=="Si, ho ricevuto la prima dose di Pfizer-BioNTech" | receivedvaccine=="Si, ho ricevuto la prima dose di Moderna" | receivedvaccine=="Si, ho ricevuto la dose di Janssen di Johnson & Johnson"
tab receivedvaccine, m sort

**Parental status
gen etafigli_02=0
replace etafigli_02=1 if regexm(etafigli, "0-2")
gen etafigli_35=0
replace etafigli_35=1 if regexm(etafigli, "3-5")
gen etafigli_611=0
replace etafigli_611=1 if regexm(etafigli, "6-11")
gen etafigli_1216=0
replace etafigli_1216=1 if regexm(etafigli, "12-16")
gen etafigli_1718=0
replace etafigli_1718=1 if regexm(etafigli, "17-18")
gen etafigli_19=0
replace etafigli_19=1 if regexm(etafigli, "19")

label define children 0 "Non parent" 1 "Parent"
gen children_018=1 if etafigli_02==1 | etafigli_35==1 | etafigli_611==1 | etafigli_1216==1 | etafigli_1718==1
replace children_018=0 if children_018==.
label var children_018 "Parent of children 0-18"
label val children_018 children

tab children_018, m 
***1,191 parents of children 0-18

**Gen outcome variable vax_kid

gen vax_kid_02=Vax_friends_1 if children_018==0
replace vax_kid_02=Vax_child_02_1 if children_018==1

gen vax_kid_35=Vax_friends_2 if children_018==0
replace vax_kid_35=Vax_child_35_1 if children_018==1

gen vax_kid_611=Vax_friends_3 if children_018==0
replace vax_kid_611=Vax_child_611_1 if children_018==1

gen vax_kid_1216=Vax_friends_4 if children_018==0
replace vax_kid_1216=Vax_child_1216_1 if children_018==1

gen vax_kid_1718=Vax_friends_5 if children_018==0
replace vax_kid_1718=Vax_child_1718_4 if children_018==1

label var vax_kid_02 "Probability to vaccinate kid 0-2 years old"
label var vax_kid_35 "Probability to vaccinate kid 3-5 years old"
label var vax_kid_611 "Probability to vaccinate kid 6-11 years old"
label var vax_kid_1216 "Probability to vaccinate kid 12-16 years old"
label var vax_kid_1718 "Probability to vaccinate kid 17-18 years old"

*Treatment 
gen Treatchild=""
replace Treatchild="Risk" if treat_child_risk==1
replace Treatchild="Herd immunity" if treat_child_herd==1
replace Treatchild="Placebo" if treat_child_placebo==1
label define treatment 0 "Placebo" 1 "Herd immunity" 2 "Risk"
encode Treatchild, gen(Treatchild_enc) label(treatment)
label var Treatchild_enc "Treatment child"

gen treatment_herd=0 if Treatchild_enc==0
replace treatment_herd=1 if Treatchild_enc==1
label define herd 0 "Placebo" 1 "Herd immunity"
label val treatment_herd herd

gen treatment_risk=0 if Treatchild_enc==0
replace treatment_risk=1 if Treatchild_enc==2
label define risk 0 "Placebo" 1 "Risk"
label val treatment_risk risk

tab Treatchild, m

***Reasons hesitancy
label var Novax_reason1_1 "Religious beliefs"
label var Novax_reason1_27 "Side effects"
label var Novax_reason1_28 "Vaccine will not work"
label var Novax_reason1_29 "Good hygiene is enough"
label var Novax_reason1_30 "It would be difficult to obtain the vaccine"
label var Novax_reason1_31 "I might accidentally miss the deadline to vaccinate"
label var Novax_reason1_32 "I'm bad with remembering things"
label var Novax_reason1_36 "I need more time to make a decision (after the summer)"
label var Novax_reason1_33 "Because most people will already be vaccinated"
label var Novax_reason1_34 "Other"

label var No_vax_friends_reas_1 "Religious beliefs"
label var No_vax_friends_reas_20 "Side effects"
label var No_vax_friends_reas_21 "Vaccine will not work"
label var No_vax_friends_reas_22 "Good hygiene is enough"
label var No_vax_friends_reas_23 "It would be difficult to obtain the vaccine"
label var No_vax_friends_reas_24 "I might accidentally miss the deadline to vaccinate"
label var No_vax_friends_reas_25 "I'm bad with remembering things"
label var No_vax_friends_reas_28 "I need more time to make a decision (after the summer)"
label var No_vax_friends_reas_26 "Because most people will already be vaccinated"
label var No_vax_friends_reas_27 "Other"

foreach var in Novax_reason1_1 Novax_reason1_27 Novax_reason1_28 Novax_reason1_29 Novax_reason1_30 Novax_reason1_31 Novax_reason1_32 Novax_reason1_36 Novax_reason1_33 Novax_reason1_34 {
	tab `var' if children_018==1, m
}

foreach var in No_vax_friends_reas_1 No_vax_friends_reas_20 No_vax_friends_reas_21 No_vax_friends_reas_22 No_vax_friends_reas_23 No_vax_friends_reas_24 No_vax_friends_reas_25 No_vax_friends_reas_28 No_vax_friends_reas_26 No_vax_friends_reas_27 {
	tab `var' if children_018==0, m
	}
	
**Trusted source of information
tab Trust_themost, m

gen trust_science=0
replace trust_science=1 if regexm(Trust_themost, "Esperti di sanitÃ  pubblica") | regexm(Trust_themost, "Il tuo dottore") | regexm(Trust_themost, "La tua farmacia locale") | regexm(Trust_themost, "Il tuo centro di assistenza sanitaria territoriale")

tab trust_science if children_018==1, m sort
tab trust_science if children_018==0, m sort	
	
***Reshape dataset
reshape long vax_kid_, i(ResponseId) j(AGE) string
drop if vax_kid_==.
label var vax_kid_ "Probability to vaccinate children"
*55 variables, 11800 obseravations

***Plots pdf and relative pdf
kdensity vax_kid_ , bwidth(3) nograph generate(x fx)

kdensity vax_kid_ if Treatchild_enc==0 & children_018==1, nograph bwidth(3) generate(p_fx0) at(x)
kdensity vax_kid_ if Treatchild_enc==1 & children_018==1, nograph bwidth(3) generate(p_fx1) at(x)
kdensity vax_kid_ if Treatchild_enc==2 & children_018==1, nograph bwidth(3) generate(p_fx2) at(x)

kdensity vax_kid_ if Treatchild_enc==0 & children_018==0, nograph bwidth(3) generate(np_fx0) at(x)
kdensity vax_kid_ if Treatchild_enc==1 & children_018==0, nograph bwidth(3) generate(np_fx1) at(x)
kdensity vax_kid_ if Treatchild_enc==2 & children_018==0, nograph bwidth(3) generate(np_fx2) at(x)

label var p_fx0 "Placebo"
label var p_fx1 "Herd immunity"
label var p_fx2 "Risk"

label var np_fx0 "Placebo"
label var np_fx1 "Herd immunity"
label var np_fx2 "Risk"

**Parents herd
line p_fx0 p_fx1 x, sort ytitle(Density) ylab(0(0.01)0.05, grid) graphregion(color(white)) xlabel(0(10)100, grid) lcolor(gs5 black) lpattern(dash)
graph save "pdf parents herd ITA", replace
reldist pdf vax_kid_ if children_018==1, by(treatment_herd) vce(cluster ResponseId) bw(0.05)
reldist graph, ciopts(fcolor(%30) lcolor(%0)) xlabel(0(.1)1, grid labsize(vlarge)) xtitle(Proportion of placebo group, size(vlarge)) ylabel(0(.5)2, grid angle(0) labsize(vlarge)) ytitle(Relative density, size(vlarge)) olabel(0(10)100, labsize(vlarge)) graphregion(color(white)) lcolor(black) refline(lcolor(gs5) lpattern(dash))
graph save "rpdf parents herd ITA", replace

**Parents risk
line p_fx0 p_fx2 x, sort ytitle(Density) ylab(0(0.01)0.05, grid) graphregion(color(white)) xlabel(0(10)100, grid) lcolor(gs5 black) lpattern(dash)
graph save "pdf parents risk ITA", replace
reldist pdf vax_kid_ if children_018==1, by(treatment_risk) vce(cluster ResponseId) bw(0.05)
reldist graph, ciopts(fcolor(%30) lcolor(%0)) xlabel(0(.1)1, grid labsize(vlarge)) xtitle(Proportion of placebo group, size(vlarge)) ylabel(0(.5)2, grid angle(0) labsize(vlarge)) ytitle(Relative density, size(vlarge)) olabel(0(10)100, labsize(vlarge)) graphregion(color(white)) lcolor(black) refline(lcolor(gs5) lpattern(dash)) 
graph save "rpdf parents risk ITA", replace

**Non parents herd
line np_fx0 np_fx1 x, sort ytitle(Density) xtitle(Probability to advise vaccination for children) ylab(0(0.01)0.05, grid) graphregion(color(white)) xlabel(0(10)100, grid) lcolor(gs5 black) lpattern(dash)
graph save "pdf non-parents herd ITA", replace
reldist pdf vax_kid_ if children_018==0, by(treatment_herd) vce(cluster ResponseId) bw(0.05)
reldist graph, ciopts(fcolor(%30) lcolor(%0)) xlabel(0(.1)1, grid labsize(vlarge)) xtitle(Proportion of placebo group, size(vlarge)) ylabel(0(.5)2, grid angle(0)labsize(vlarge)) ytitle(Relative density, size(vlarge)) olabel(0(10)100, labsize(vlarge)) graphregion(color(white)) lcolor(black) refline(lcolor(gs5) lpattern(dash))
graph save "rpdf non-parents herd ITA", replace

**Non parents risk  
line np_fx0 np_fx2 x, sort ytitle(Density) xtitle(Probability to advise vaccination for children) ylab(0(0.01)0.05, grid) graphregion(color(white)) xlabel(0(10)100, grid) lcolor(gs5 black) lpattern(dash)
graph save "pdf non-parents risk ITA", replace
reldist pdf vax_kid_ if children_018==0, by(treatment_risk) vce(cluster ResponseId) bw(0.05)
reldist graph, ciopts(fcolor(%30) lcolor(%0)) xlabel(0(.1)1, grid labsize(vlarge)) xtitle(Proportion of placebo group, size(vlarge)) ylabel(0(.5)2, grid angle(0) labsize(vlarge)) ytitle(Relative density, size(vlarge)) olabel(0(10)100, labsize(vlarge)) graphregion(color(white)) lcolor(black) refline(lcolor(gs5) lpattern(dash)) 
graph save "rpdf non-parents risk ITA", replace


